<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>

</head>

<script>



    function test1 () {
        return new Promise(resolve => {
            setTimeout(()=>{
                resolve('请求1')
            }, 1000)
        })
    }
    
    
    function test2 (value) {
        return new Promise(resolve => {
            setTimeout(()=>{
                resolve('请求2' + value)
            }, 2000)
        })
    }
    
    
    function test3 (value) {
        return new Promise(resolve => {
            setTimeout(()=>{
                resolve('请求3' + value)
            }, 3000)
        })
    }
    
    
    async function send () {
        console.log('顺序执行async中代码1, 直至遇到await停止然后等待其expression执行完毕后继续顺序执行直至await后再次停止')
        let return_value = await test1()
        console.log('test()1 执行完毕')
        console.log('顺序执行async中代码2, 直至遇到await停止然后等待其expression执行完毕后继续顺序执行直至await后再次停止')
        let return_value2 = await test2(return_value)
        console.log('test()2 执行完毕')
        console.log('顺序执行async中代码3, 直至遇到await停止然后等待其expression执行完毕后继续顺序执行直至await后再次停止')
        let return_value3 = await test2(return_value2)
        console.log('test()3 执行完毕')
        console.log(return_value3)
        
        return 'async function最后返回的Promise能够读取'
    }
    
    var p = send()
    console.log(p)

</script>

<body>

</body>

</html>
